<me:UIKS03 x:Class="WPFExcelReport.MKS03"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"  
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                     xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"   
                     xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR"  
                    xmlns:KSZ="clr-namespace:WPFExcelReport;assembly=TKSTAGZUO"  
                    xmlns:APK="clr-namespace:WPFExcelReport;assembly=TAPKOPF" 
                    xmlns:AM="clr-namespace:WPFExcelReport;assembly=TAMSTAMM"  
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIKS03.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:Divideby10  x:Key="d10"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter  x:Key="nbv"/>
        <ucd:NOTConverter x:Key="not"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIKS03.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>            
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="400"></ColumnDefinition>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0" >
            <StackPanel  VerticalAlignment="Top"  >
                <WrapPanel Visibility="Collapsed">
                    <Button Click="ResetSeq" Content="{Binding Source={Localization:Translate Word=重置序列号}}"
                    Visibility="{Binding IsITX,Converter={StaticResource bv}}"/>

                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"   
                      >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <DR:TDRAUFTR  Grid.Column="0" Name="cDR" DocType="{Binding PRTYPE,ElementName=TV}" PrintType="OpenExcel" />
                        <Button  Grid.Column="1"   Click="btnPrint_Click" Height="20" Margin="5,0,0,0" Width="Auto" Content="{Binding Source={Localization:Translate Word=打印确认函}}" />
                    </Grid>
                </WrapPanel>
                <WrapPanel>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource nbv}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button  Click="EditCommand" Width="24" Height="20">
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                            </Button.Background>
                        </Button>
                    </Grid> 
                   
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=成本中心}}"/>
                        <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"   IsAutoClear="True" 
                              CharacterCasing="Upper" Text="{Binding KRS,ElementName=TV}" Width="30" />
                        <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="4"  IsAutoClear="True" 
                              Text="{Binding LFD,ElementName=TV}" KeyUp="Query_KeyUp" Width="90" />
                    </Grid>
                    <Grid Margin="10,0,0,0"  VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                            </Button.Background>
                        </Button>
                        <TextBlock Grid.Column="2" FontSize="16" Text="{Binding Source={Localization:Translate Word=查询}}"/>
                    </Grid>
                </WrapPanel>
                <WrapPanel>
                    <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24"
                            IsEnabled="{Binding IsCanNew,ElementName=TV}"
                            >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                        </Button.Background>
                    </Button>
                    <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}">
                        <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"  
                          PRE="  "
                              CharacterCasing="Upper" Text="{Binding KRS,ElementName=TV}" Width="30" />
                        <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="4"   
                          PRE="0000"
                              Text="{Binding LFD,ElementName=TV}"   Width="90" />
                        <Grid Margin="10,0,0,0"  VerticalAlignment="Top" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/button_ok.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                    </WrapPanel>
                </WrapPanel>
                <me:TUIKS03 Grid.Column="0" x:Name="cKS03"  
                      IsEdit="{Binding IsEdit,ElementName=TV}"
                      IsSaved="{Binding IsSaved,ElementName=TV}"
                      />
            </StackPanel>
        </StackPanel>
        <DataGrid  Grid.Row="1"  Grid.Column="0" 
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"     
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding KSTKSTKRS}" Width="Auto"/>
                <DataGridTextColumn Binding="{Binding KSTKST}" Header="{Binding Source={Localization:Translate Word=成本中心}}" Width="Auto"/>
                <DataGridTextColumn  Binding="{Binding KSTBEZ,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=说明}}" Width="Auto"/>
            </DataGrid.Columns>
        </DataGrid  >
        <TabControl  Grid.Row="2" Grid.Column="0">
            <TabItem Header="{Binding Source={Localization:Translate Word=操作管理}}" Name="ZoneOP" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
                <KSZ:TKSTAGZUO    IsCanLoad="{Binding IsSelected,ElementName=ZoneOP}"
                                  Name="cKS05" 
                                  IsEdit="{Binding IsEdit,ElementName=TV}"
                                  IsSaved="{Binding IsSaved,ElementName=TV}"
                                  EXAUF="{Binding KEY,ElementName=TV}"
                            />
            </TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=设备清单}}" Name="ZoneAM" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
                <AM:TKSAM02 IsCanLoad="{Binding IsSelected,ElementName=ZoneAM}"
                   EXAUF="{Binding KEY,ElementName=TV}"/>
            </TabItem> 
        </TabControl>
        <APK:TFPSTPCOND  Grid.Row="0" Grid.RowSpan="4" Grid.Column="1"
                    IsAuto="{Binding IsEdit,ElementName=cKS05}"
                    DES="{Binding KEY,ElementName=cKS05}"
                    QTY="9"
                    IsEdit="{Binding IsEdit,ElementName=TV}"
                    IsSaved="{Binding IsSaved,ElementName=TV}"
                    EXAUF="{Binding KEY,ElementName=cKS05}"/>
    </Grid>
</me:UIKS03>
